package com.pocket.insight.service.impl;

import com.pocket.insight.base.sql.dataset.DatasetProxy;
import com.pocket.insight.base.sql.dataset.DatasetUtil;
import com.pocket.insight.controller.dto.DatasetResultDto;
import com.pocket.insight.controller.dto.SqlParam;
import com.pocket.insight.entity.Dataset;
import com.pocket.insight.service.DatasetService;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 描述：
 *
 * @author shuize
 * @create 2024/12/4
 */
@Service
public class DatasetServiceImpl implements DatasetService {
    @Override
    public Dataset getDatasetWithAuth(Dataset dataset) {
        // 预览数据集不需要权限控制
        if (dataset.getId() == null) {
            return dataset;
        }
        return dataset;
    }

    @Override
    public Dataset getById(Long appId, Long datasetId) {
        return null;
    }

    @Override
    public DatasetResultDto previewDataAndSchema(Dataset dataset, SqlParam sqlParam) {
        DatasetProxy datasetProxy = DatasetProxy.create(dataset);
        DatasetResultDto resultDto = datasetProxy.fetchDatasetData(sqlParam);
        return resultDto;
    }

    @Override
    public void batchFetchDatasetsInfo(Long appId, List<Long> datasetIds, Boolean isSecondTime) {
    }
}
